<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: Spec::Rails::Example::HelperExampleGroup</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">Spec::Rails::Example::HelperExampleGroup</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../../files/vendor/plugins/rspec-rails/lib/spec/rails/example/helper_example_group_rb.html">
                vendor/plugins/rspec-rails/lib/spec/rails/example/helper_example_group.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="FunctionalExampleGroup.html">
                FunctionalExampleGroup
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
Helper Specs live in $RAILS_ROOT/spec/helpers/.
</p>
<p>
Helper Specs use <a
href="HelperExampleGroup.html">Spec::Rails::Example::HelperExampleGroup</a>,
which allows you to include your Helper directly in the context and write
specs directly against its methods.
</p>
<p>
<a href="HelperExampleGroup.html">HelperExampleGroup</a> also includes the
standard lot of ActionView::Helpers in case your helpers rely on any of
those.
</p>
<h2><a href="../Example.html">Example</a></h2>
<pre>
  class ThingHelper
    def number_of_things
      Thing.count
    end
  end

  describe &quot;ThingHelper example_group&quot; do
    include ThingHelper
    it &quot;should tell you the number of things&quot; do
      Thing.should_receive(:count).and_return(37)
      number_of_things.should == 37
    end
  end
</pre>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000038">_assigns_hash_proxy</a>&nbsp;&nbsp;
      <a href="#M000036">eval_erb</a>&nbsp;&nbsp;
      <a href="#M000035">flash</a>&nbsp;&nbsp;
      <a href="#M000034">helper</a>&nbsp;&nbsp;
      <a href="#M000033">helper</a>&nbsp;&nbsp;
      <a href="#M000032">helper_name</a>&nbsp;&nbsp;
      <a href="#M000037">protect_against_forgery?</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">

    <div id="class-list">
      <h3 class="section-bar">Classes and Modules</h3>

      Class <a href="HelperExampleGroup/HelperObject.html" class="link">Spec::Rails::Example::HelperExampleGroup::HelperObject</a><br />

    </div>




      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000033" class="method-detail">
        <a name="M000033"></a>

        <div class="method-heading">
          <a href="#M000033" class="method-signature">
          <span class="method-name">helper</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000033-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000033-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec-rails/lib/spec/rails/example/helper_example_group.rb, line 65</span>
65:           <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">helper</span>
66:             <span class="ruby-ivar">@helper_object</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">returning</span> <span class="ruby-constant">HelperObject</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">helper_object</span><span class="ruby-operator">|</span>
67:               <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@helper_being_described</span>.<span class="ruby-identifier">nil?</span>
68:                 <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">described_type</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Module</span>
69:                   <span class="ruby-identifier">helper_object</span>.<span class="ruby-identifier">extend</span> <span class="ruby-identifier">described_type</span>
70:                 <span class="ruby-keyword kw">end</span>
71:               <span class="ruby-keyword kw">else</span>
72:                 <span class="ruby-identifier">helper_object</span>.<span class="ruby-identifier">extend</span> <span class="ruby-ivar">@helper_being_described</span>
73:               <span class="ruby-keyword kw">end</span>
74:             <span class="ruby-keyword kw">end</span>
75:           <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000032" class="method-detail">
        <a name="M000032"></a>

        <div class="method-heading">
          <a href="#M000032" class="method-signature">
          <span class="method-name">helper_name</span><span class="method-args">(name=nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
The <a href="HelperExampleGroup.html#M000033">helper</a> name.&#8230;
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000032-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000032-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec-rails/lib/spec/rails/example/helper_example_group.rb, line 60</span>
60:           <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">helper_name</span>(<span class="ruby-identifier">name</span>=<span class="ruby-keyword kw">nil</span>)
61:             <span class="ruby-ivar">@helper_being_described</span> = <span class="ruby-node">&quot;#{name}_helper&quot;</span>.<span class="ruby-identifier">camelize</span>.<span class="ruby-identifier">constantize</span>
62:             <span class="ruby-identifier">send</span> <span class="ruby-identifier">:include</span>, <span class="ruby-ivar">@helper_being_described</span>
63:           <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000036" class="method-detail">
        <a name="M000036"></a>

        <div class="method-heading">
          <a href="#M000036" class="method-signature">
          <span class="method-name">eval_erb</span><span class="method-args">(text)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000036-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000036-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/rspec-rails/lib/spec/rails/example/helper_example_group.rb, line 130</span>
130:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">eval_erb</span>(<span class="ruby-identifier">text</span>)
131:           <span class="ruby-identifier">erb_args</span> = [<span class="ruby-identifier">text</span>]
132:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">helper</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:output_buffer</span>)
133:             <span class="ruby-identifier">erb_args</span> <span class="ruby-operator">+=</span> [<span class="ruby-keyword kw">nil</span>, <span class="ruby-keyword kw">nil</span>, <span class="ruby-value str">'@output_buffer'</span>]
134:           <span class="ruby-keyword kw">end</span>
135:           
136:           <span class="ruby-identifier">helper</span>.<span class="ruby-identifier">instance_eval</span> <span class="ruby-keyword kw">do</span>
137:             <span class="ruby-constant">ERB</span>.<span class="ruby-identifier">new</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">erb_args</span>).<span class="ruby-identifier">result</span>(<span class="ruby-identifier">binding</span>)
138:           <span class="ruby-keyword kw">end</span>
139:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000035" class="method-detail">
        <a name="M000035"></a>

        <div class="method-heading">
          <a href="#M000035" class="method-signature">
          <span class="method-name">flash</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000035-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000035-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/rspec-rails/lib/spec/rails/example/helper_example_group.rb, line 126</span>
126:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">flash</span>
127:           <span class="ruby-ivar">@flash</span>
128:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000034" class="method-detail">
        <a name="M000034"></a>

        <div class="method-heading">
          <a href="#M000034" class="method-signature">
          <span class="method-name">helper</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns an instance of ActionView::Base with the <a
href="HelperExampleGroup.html#M000033">helper</a> being spec&#8216;d
included.
</p>
<h2><a href="../Example.html">Example</a></h2>
<pre>
  describe PersonHelper do
    it &quot;should write a link to person with the name&quot; do
      assigns[:person] = mock_model(Person, :full_name =&gt; &quot;Full Name&quot;, :id =&gt; 37, :new_record? =&gt; false)
      helper.link_to_person.should == %{&lt;a href=&quot;/people/37&quot;&gt;Full Name&lt;/a&gt;}
    end
  end

  module PersonHelper
    def link_to_person
      link_to person.full_name, url_for(person)
    end
  end
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000034-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000034-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec-rails/lib/spec/rails/example/helper_example_group.rb, line 96</span>
96:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">helper</span>
97:           <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">helper</span>
98:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000037" class="method-detail">
        <a name="M000037"></a>

        <div class="method-heading">
          <a href="#M000037" class="method-signature">
          <span class="method-name">protect_against_forgery?</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
TODO: BT - Helper Examples should proxy method_missing to a <a
href="../../Rails.html">Rails</a> View instance. When that is done, remove
this method
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000037-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000037-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/rspec-rails/lib/spec/rails/example/helper_example_group.rb, line 143</span>
143:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">protect_against_forgery?</span>
144:           <span class="ruby-keyword kw">false</span>
145:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Protected Instance methods</h3>

      <div id="method-M000038" class="method-detail">
        <a name="M000038"></a>

        <div class="method-heading">
          <a href="#M000038" class="method-signature">
          <span class="method-name">_assigns_hash_proxy</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000038-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000038-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/rspec-rails/lib/spec/rails/example/helper_example_group.rb, line 150</span>
150:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">_assigns_hash_proxy</span>
151:           <span class="ruby-ivar">@_assigns_hash_proxy</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">AssignsHashProxy</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">self</span> <span class="ruby-keyword kw">do</span>
152:             <span class="ruby-identifier">helper</span>
153:           <span class="ruby-keyword kw">end</span>
154:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>